<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        // 成功
        let p1 = new Promise((resolve, reject)=>{
            if(!true) {
                // 成功时调用resolve
                resolve('我成功了')
            }else {
                // 失败时调用reject
                reject('我是成功之母')
            }
        })
        console.log(p1);
        p1.then(res=>{
            // result 结果  response 响应
            console.log(1,res);
        }, err => {
            console.log(2,err);
        })

        let time = (ms) => {
            return new Promise((resolve, reject) => {
                setTimeout(()=>{
                    reject('我出错了。。。')
                }, ms)
            })
        }
        let t1 = time(2000);
        // console.log(t1);  需要通过then方法接收，否则浏览器会报错：Uncaught
        t1.then(res=>{
            console.log(111, '等不到的爱。。。');
        }, err => {
            console.log(222, err);
        })
    </script>
</body>
</html>